#include <iostream>

using namespace std;

//二分法查找(数组arr需要有序)
bool binaryFind(int arr[], int Size, int num)
{
    if (arr == nullptr || Size == 0)
    {
        return false;
    }
    int L = 0;
    int R = Size - 1;
    while (L <= R)
    {
        int mid = L + ((R - L) >> 1);
        if (num == arr[mid])
        {
            return true;
        }
        else if (num <= arr[mid])
        {
            R = mid - 1;
        }
        else
        {
            L = mid + 1;
        }
    }
    return false;
}

int main()
{
    int arr[] = {4, 13, 16, 27, 38, 48, 49, 55, 65, 76, 97};
    bool result = binaryFind(arr, 11, 38);
    cout << result << endl;
    system("pause");
    return 0;
}